import Vue from 'vue';
import Vuex from 'vuex';

import user from './user.js';

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    count: 0,
  },
  mutations: {
    addCount(state, payload) {
      state.count += payload;
    },
  },
  actions: {
    addCountAsync($store, payload) {
      setTimeout(() => {
        $store.commit('addCount', payload);
      }, 1000);
    },
  },
  modules: {
    user,
    settings: {
      state: {
        name: 'Vuex',
      },
    },
  },
});
